<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.9.0/vconsole.min.js"></script>
<script>
  var vConsole = new VConsole();
</script>
<script src="https://www.WebRTC-Experiment.com/RecordRTC.js"></script>
<script>
  window.onload = function () {

  }
  async function record() {
    let stream = await navigator.mediaDevices.getUserMedia({
      audio: true
    });
    let recorder = new RecordRTCPromisesHandler(stream, {
        type: 'audio',
        mimeType: 'audio/wav',
    });
    recorder.startRecording();

    const sleep = m => new Promise(r => setTimeout(r, m));
    await sleep(3000);

    await recorder.stopRecording();
    let blob = await recorder.getBlob();
    invokeSaveAsDialog(blob, '录音.wav');
  }
</script>
<body>
  <button onclick="record()">开始</button>
</body>
</html>